package cn.tedu.demo04wy.mapper;
import cn.tedu.demo04wy.entity.Commodity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CommodityMapper {

    @Select("select id,title,intro,author,time,url,price,sales from commodity order by sales desc limit 0,3")
    List<Commodity> selectC2();

    @Select("select id,title,url,price,sales from commodity order by sales desc limit 0,12")
    List<Commodity> selectC1();


    @Update("update commodity set count=count+1 where id=#{id}")
    void addCount(int id);

    @Update("update commodity set count=count-1 where id=#{id}")
    void reduceCount(int id);

    @Insert("insert into commodity values(null,#{title},#{intro},#{author},#{time},#{url},null,#{price},null,null,#{categoryId})")
    void insert(Commodity commodity);
}
